package com.gxitsky.common.utils;

/**
 * @desc: 文件 Content Type
 * @author: gxing
 * @date: 2020/5/13
 */
public class ContentTypeUtil {

    public static String getContentType(String extension) {

        if (extension.equalsIgnoreCase(".bmp")) {
            return "image/bmp";
        }
        if (extension.equalsIgnoreCase(".gif")) {
            return "image/gif";
        }
        if (extension.equalsIgnoreCase(".jpeg") ||
                extension.equalsIgnoreCase(".jpg") ||
                extension.equalsIgnoreCase(".png")) {
            return "image/jpg";
        }
        if (extension.equalsIgnoreCase(".html")) {
            return "text/html";
        }
        if (extension.equalsIgnoreCase(".txt")) {
            return "text/plain";
        }
        if (extension.equalsIgnoreCase(".vsd")) {
            return "application/vnd.visio";
        }
        if (extension.equalsIgnoreCase(".pptx") ||
                extension.equalsIgnoreCase(".ppt")) {
            return "application/vnd.ms-powerpoint";
        }
        if (extension.equalsIgnoreCase(".docx") ||
                extension.equalsIgnoreCase(".doc")) {
            return "application/msword";
        }
        if (extension.equalsIgnoreCase(".xml")) {
            return "text/xml";
        }
        return null;
    }
}
